<template>
  <div class="box">
    <el-row>
      <el-col :span="24">
        <div class="header">
          <el-form ref="form" label-width="100px" class="flex">
            <div style="display: flex;">
              <div style="margin-left: 10px; width: 386px">
                <el-form-item label="统计日期">
                  <datePick label="统计日期" @dataTime="handleDataTime" />
                </el-form-item>
              </div>
              <el-form-item label="网点名称" style="margin-left: 10px">
                <networkSelect :value="'请选择所属网点'" @select="handleSelect" />
              </el-form-item>
            </div>
            <el-form-item>
              <el-button type="primary" @click="onSubmit">查询</el-button>
              <el-button>重置</el-button>
            </el-form-item>
          </el-form>
        </div>
      </el-col>
    </el-row>
    <el-row v-if="!isObjectEmpty(infoCollectObj)" type="flex" justify="space-between">
      <el-col v-for="(item, index) in infoCollectObj.cards" :key="index" :span="8">
        <div class="liLittle">
          <span style="padding-left: 40px">{{ item.tittle }}</span>
          <div class="f-row">
            <div v-for="(cardItem, cardIndex) in item.cardList" :key="cardIndex" class="littbox">
              <span style="font-size: 18px">{{ cardItem.name1 }}</span>
              <span style="font-size: 18px; color: #2087d0">{{ cardItem.num1 }}票</span>
              <span v-if="cardItem.rate1 != null" style="font-size: 20px">{{ Number(cardItem.rate1) * 100 }}%</span>
              <span v-if="cardItem.rateName1 != null" style="font-size: 20px">{{ cardItem.rateName1 }} :
                {{ Number(cardItem.ratelanshou) * 100 }}%</span>
              <span v-if="cardItem.rateName2 != null" style="font-size: 20px">{{ cardItem.rateName2 }} :{{
                Number(cardItem.rateGet) * 100
              }}%</span>
            </div>
          </div>
        </div>
      </el-col>
    </el-row>
    <el-row v-if="isObjectEmpty(infoCollectObj)" type="flex" justify="center">
      <empty />
    </el-row>
    <el-tabs v-model="dataParams.type" @tab-click="handleClick">
      <el-row type="flex" justify="space-between">
        <el-col v-if="!isObjectEmpty(infoCollectObj)" :span="6">
          <div>当前页共{{ infoCollectObj.sheets.list.total }}项</div>
        </el-col>
      </el-row>
      <el-tab-pane label="及时性" name="inTime">
        <el-row type="flex" justify="space-between">
          <el-col :span="24">
            <elltable v-if="!isObjectEmpty(infoCollectObj)" :data="infoCollectObj.sheets.list.data" :loading="false" :th="infoCollectObj.sheets.fields" />
            <empty v-if="isObjectEmpty(infoCollectObj)" />
          </el-col>
        </el-row>
      </el-tab-pane>
      <el-tab-pane label="完整性" name="accuracy">
        <el-row type="flex" justify="space-between">
          <el-col :span="24">
            <elltable v-if="!isObjectEmpty(infoCollectObj)" :data="infoCollectObj.sheets.list.data" :loading="false" :th="infoCollectObj.sheets.fields" />
            <empty v-if="isObjectEmpty(infoCollectObj)" />
          </el-col>
        </el-row>
      </el-tab-pane>
      <el-tab-pane label="准确性" name="integrity">
        <el-row type="flex" justify="space-between">
          <el-col :span="24">
            <elltable v-if="!isObjectEmpty(infoCollectObj)" :data="infoCollectObj.sheets.list.data" :loading="false" :th="infoCollectObj.sheets.fields" />
            <empty v-if="isObjectEmpty(infoCollectObj)" />
          </el-col>
        </el-row>
      </el-tab-pane>
      <div v-if="!isObjectEmpty(infoCollectObj)" class="block" style="display: flex; justify-content: flex-end">
        <pagination :current-page="dataParams.pageDate.pageNum" :page-size="dataParams.pageDate.pageSize" :total="infoCollectObj.sheets.list.total" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
      </div>
    </el-tabs>
  </div>
</template>
<script>
import datePick from '@/components/menuComponent/datePick.vue'
import networkSelect from '@/components/menuComponent/NetworkSelect.vue'
import timeExamine from '@/api/zhijian/time'
import empty from '@/components/menuComponent/empty.vue'
export default {
  components: {
    datePick,
    networkSelect,
    empty
  },
  data() {
    return {
      dataParams: {
        endTime: '',
        networkNameId: 0,
        pageDate: {
          pageNum: 1,
          pageSize: 100
        },
        startTime: '',
        type: 'inTime'
      },
      infoCollectObj: {},
      activeName: 'first'
    }
  },
  methods: {
    handleClick() {
      this.getInfoCollectList()
      console.log(this.dataParams)
    },
    handleSizeChange(val) {
      this.dataParams.pageDate.pageSize = val
      this.getSheetCollect()
      console.log('改变size', val)
    },
    handleCurrentChange(val) {
      this.dataParams.pageDate.pageNum = val
      this.getSheetCollect()
      console.log('改变页码', val, this.dataParams)
    },
    handleDataTime(val) {
      this.dataParams.startTime = val[0]
      this.dataParams.endTime = val[1]
      // this.getTimeAll()
    },
    handleSelect(val) {
      this.dataParams.networkNameId = val
      console.log('select', val)
      //   this.getTimeAll()
    },
    onSubmit() {
      this.getInfoCollectList()
      console.log('提交', this.dataParams)
    },
    isObjectEmpty(obj) {
      return Object.keys(obj).length === 0
    },
    getInfoCollectList() {
      timeExamine.infoCollectList(this.dataParams).then((res) => {
        if (res.code === 200) {
          this.infoCollectObj = res.data
          console.log('信息指数考核res', res)
        }
      })
    }
  }
}
</script>
<style
  lang="scss"
  scoped
>
.box {
  padding: 0px 20px;
}

.flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}

.liLittle {
  border: 1px solid #ece7e7d6;
  height: 150px;
  display: flex;
  flex-flow: column;
  justify-content: space-around;
}

.liLittle > span {
  font-size: 24px;
}

.f-row {
  display: flex;
  flex-flow: row;
  justify-content: space-around;
}

.littbox {
  display: flex;
  flex-flow: column;
  gap: 10px;
  height: 100px;
}

.flex-bettom {
  display: flex;
  justify-content: space-between;
}

.header {
  padding: 20px 0;
  border-bottom: 1px solid #ccc;
}

.el-row {
  margin-bottom: 20px;

  &:last-child {
    margin-bottom: 0;
  }
}

.el-col {
  border-radius: 4px;
}

.bg-purple-dark {
  background: #99a9bf;
}

.bg-purple {
  background: #d3dce6;
}

.bg-purple-light {
  background: #e5e9f2;
}

.grid-content {
  border-radius: 4px;
  min-height: 36px;
}

.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}
</style>
